package com.company;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.Scanner;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
public class Main {
    public static void main(String[] args) throws Exception{
        Teacher teacher1 = new Teacher(001,"李老师","男","nothing",0,43);
        Teacher teacher2 =new Teacher(002,"王老师","女","nothing",0,37);
        Student student1 = new Student(2021310000,"小明","男","nothing",0,"大二");
        Student student2 = new Student(2021310001,"小红","女","nothing",0,"大三");
        Course course1= new Course(001,"数学","教100","上午8：00","nothing",0,0);
        Course course2= new Course(002,"英语","教101","下午18：30","nothing",0,0);
        System.out.println("是否读取已有文件，按1读取，其他数字跳过：");
        Scanner input7=new Scanner(System.in);
        int c7=input7.nextInt();
        while(c7==1){
            System.out.println("输入读取路径");
            Scanner input8=new Scanner(System.in);
            String c8=input8.next();
        FileInputStream inputStream = new FileInputStream(c8);
        ObjectInputStream mms = new ObjectInputStream(inputStream);
        Sequence sequence1 = (Sequence) mms.readObject();
        teacher1.course= sequence1.courseT1;
        teacher2.course= sequence1.courseT2;
        teacher1.course1=sequence1.course1T1;
        teacher2.course1=sequence1.course1T2;
        student1.course= sequence1.courseS1;
        student2.course=sequence1.courseS2;
        student1.course1= sequence1.course1S1;
        student2.course1= sequence1.course1S2;
        course1.course= sequence1.teacherC1;
        course2.course= sequence1.teacherC2;
        course1.course1= sequence1.teacher1C1;
        course2.course1= sequence1.teacher1C2;
        mms.close();
        break;}
       System.out.println("输入字符1开始系统：");
        Scanner input1=new Scanner(System.in);
        int c1=input1.nextInt();
        while(c1==1) {
            System.out.println("按1开始老师开课，按2开始学生选课,按3为学生退课,按4查看课表,按5保存信息，按6结束系统");
            Scanner input2=new Scanner(System.in);
            int c2=input2.nextInt();
            if(c2==1){
                teacher1.tchoice(teacher1,teacher2,course1,course2);
            }
            if(c2==2){
                student1.choice(student1,student2,course1,course2);
            }
            if(c2==3){
                student1.nochoice(student1,student2,course1,course2);
            }
            if(c2==4){
                course1.Timetable(student1,student2,course1,course2);
            }
            if(c2==5){
                System.out.println("输入保存路径：");
                Scanner input9=new Scanner(System.in);
                String c9=input9.next();
                FileOutputStream fos = new FileOutputStream(c9);
                ObjectOutputStream oos = new ObjectOutputStream(fos);
                Sequence sequence2=new Sequence(teacher1.course,teacher2.course,teacher1.course1, teacher2.course1, student1.course, student2.course, student1.course1, student2.course1, course1.teacher, course2.teacher, course1.teacher1, course2.teacher1);
                oos.writeObject(sequence2);
                oos.close();
            }
            if(c2==6){
                break;
            }
        }
    }
}


